package com.xunji.standard.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xunji.standard.entity.TXjNdFlAlipayInformation;
import com.xunji.standard.entity.TXjNdFlPersonInformation;
import com.xunji.standard.mapper.TXjNdFlAlipayInformationMapper;
import com.xunji.standard.service.TXjNdFlAlipayInformationService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 * @description 针对表【t_xj_nd_fl_alipay_information】的数据库操作Service实现
 * @createDate 2025-08-18 14:38:40
 */
@Service
public class TXjNdFlAlipayInformationServiceImpl extends ServiceImpl<TXjNdFlAlipayInformationMapper, TXjNdFlAlipayInformation>
        implements TXjNdFlAlipayInformationService {
    @Override
    public List<TXjNdFlAlipayInformation> selectListByCaseIdAndInfoId(String caseId, Long infoId, String xm, String sfzh, List<String> lxfsList) {
        if (lxfsList == null || lxfsList.isEmpty()) {
            return new ArrayList<>();
        }
        QueryWrapper<TXjNdFlAlipayInformation> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId)
                //.in(!lxfsList.isEmpty(), "dlsj", lxfsList)
                .eq(!StringUtils.isEmpty(sfzh), "zjh", sfzh);
        return this.baseMapper.selectList(qw);
    }

    @Override
    public List<TXjNdFlAlipayInformation> selectListByCaseIdAndXmAndSfzh(String caseId, String xm, String sfzh) {
        QueryWrapper<TXjNdFlAlipayInformation> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId).eq("zjh", sfzh);
        return this.baseMapper.selectList(qw);
    }

    @Override
    public void deleteByCaseId(String caseId, String xm, String sfzh) {
        QueryWrapper<TXjNdFlAlipayInformation> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId).eq(!StringUtils.isEmpty(sfzh), "zjh", sfzh);
        this.baseMapper.delete(qw);
    }

    @Override
    public void updateOwnerInfo(String caseId, TXjNdFlPersonInformation personInformation, TXjNdFlPersonInformation ownerInformation, Long commonModifyId) {
        TXjNdFlAlipayInformation alipayInformation = this.getById(commonModifyId);
        if (alipayInformation != null) {
            alipayInformation.setZjh(ownerInformation.getSfzh());
            this.updateById(alipayInformation);
        }
    }
}
